package com.infore.remoteControl.entity.instructionsEntity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * 指令类
 * @author Cold
 *
 */
@Entity
@Table(name="INSTRUCTIONS")
@NamedQuery(name="Instructions.findAll", query="SELECT i FROM Instructions i")
public class Instructions implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="INSTRUCTIONS_ID")
	@GeneratedValue(generator = "uuidGenerator")
	@GenericGenerator(name = "uuidGenerator", strategy = "uuid") // UUID生成策略
	private String instructionsId;
	
	/** 指令编号 **/
	@Column(name="CODE", unique = true, length = 10)
	private String code;
	
	/** 内容模板 **/
	@Column(name="CONTENTTEMPLATE", length = 200)
	private String contenttemplate;
	
	/** 指令类型ID(与指令类型关联) **/
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE) 
	@JoinColumn(name = "INSTRUCTIONS_TYPE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	private InstructionsType instructionsType;
	
	/** 指令名称 **/
	@Column(name="NAME", unique = true, length = 20)
	private String name;
	
	/** 指令序号 **/
	@Column(name="NUMBERS", length = 10)
	private String numbers;
	
	/** 指令数据ID(与指令数据关联) **/
	@JsonIgnoreProperties(value = {"instructions"})
	@OneToMany(mappedBy = "instructions", cascade = {CascadeType.REMOVE, CascadeType.MERGE})
	@NotFound(action = NotFoundAction.IGNORE)
	private Set<InstructionsData> instructionsData;

	public Instructions() {
	}

	public String getInstructionsId() {
		return instructionsId;
	}

	public void setInstructionsId(String instructionsId) {
		this.instructionsId = instructionsId;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getContenttemplate() {
		return contenttemplate;
	}

	public void setContenttemplate(String contenttemplate) {
		this.contenttemplate = contenttemplate;
	}

	public InstructionsType getInstructionsType() {
		return instructionsType;
	}

	public void setInstructionsType(InstructionsType instructionsType) {
		this.instructionsType = instructionsType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNumbers() {
		return numbers;
	}

	public void setNumbers(String numbers) {
		this.numbers = numbers;
	}

	public Set<InstructionsData> getInstructionsData() {
		return instructionsData;
	}

	public void setInstructionsData(Set<InstructionsData> instructionsData) {
		this.instructionsData = instructionsData;
	}

}